package LeetCode.exercise;

import java.util.Scanner;

public class LC_434 {
    public static int countSegments(String s) {
        String[] strings = s.split(" ");
        int count = 0;
        for (int i = 0; i < strings.length; i++) {
            if(!strings[i].equals("")){
                count++;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        String s = "Hello, my   name is John";
        System.out.println(countSegments(s));
    }
}
